home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / buildPanelPopupMenu.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  10.1 KB  |  340 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date: 
  22. //  Author:        
  23. //
  24.  
  25. global proc buildPanelSubItemsNow (string $subMenuName, string $panelName) {
  26.  
  27.        setParent -m $subMenuName;
  28.     if (0 == `menu -q -numberOfItems $subMenuName`) {
  29.         newPanelItems $panelName;
  30.     }
  31.  
  32. }
  33.  
  34. global proc buildOtherPanelSubItemsNow (string $subMenuName, string $panelName)
  35. {
  36.     string $state[];
  37.     int $count = 0;
  38.     string $label;
  39.  
  40.     string $panels[] = `getPanel -allPanels`;
  41.  
  42.     for ($panel in $panels) {
  43.         string $type = `getPanel -typeOf $panel`;
  44.         $label = `panel -q -label $panel`;
  45.  
  46.         // Skip Top, Front, Side, and Persp Panels
  47.         //
  48.         if (($type != "modelPanel" ||
  49.              ("Top View" != $label && "Front View" != $label &&
  50.              "Side View" != $label && "Persp View" != $label)) &&
  51.             $type != "emptyPanel") 
  52.         {
  53.             string $realType;
  54.             if ($type == "scriptedPanel") {
  55.                 $realType = `scriptedPanel -q -type $panel`;
  56.             } else {
  57.                 $realType = $type;
  58.             }
  59.             if ( ( $realType == "blendShapePanel")
  60.                     && (!`licenseCheck -m "edit" -typ "complete"`)) {
  61.                 //
  62.                 // The user needs a Maya Complete license to use
  63.                 // the BlendShape panel, so don't
  64.                 // bother offerring it as a choice (would just
  65.                 // bring up a useless blank panel anyway)
  66.                 continue;
  67.             }
  68.             $state[$count++] = $panel;
  69.             $state[$count++] = `panel -q -to $panel`;
  70.         }
  71.     }
  72.  
  73.     if (associateWithKey($subMenuName, $state)) return;
  74.  
  75.     // Rebuild menu
  76.     //
  77.  
  78.     setParent -m $subMenuName;
  79.  
  80.     popupMenu -e -deleteAllItems $subMenuName;
  81.  
  82.     string $command;
  83.     string $item;
  84.     int    $kNumItemsPerDivider = 3;
  85.  
  86.     $count = 0;
  87.     for ($i in $panels) {
  88.  
  89.         if ($count > 0 && ($count%$kNumItemsPerDivider == 0)) {
  90.             menuItem -divider true;
  91.         }
  92.  
  93.         $command = `getPanel -typeOf $i`;
  94.         $label = `panel -q -label $i`;
  95.  
  96.          // Skip Top, Front, Side, and Persp Panels
  97.         //
  98.        if (($command != "modelPanel" ||
  99.              ("Top View" != $label && "Front View" != $label &&
  100.              "Side View" != $label && "Persp View" != $label)) &&
  101.             $command != "emptyPanel") 
  102.         {
  103.             string $realType;
  104.             if ($command == "scriptedPanel") {
  105.                 $realType = `scriptedPanel -q -type $i`;
  106.             } else {
  107.                 $realType = $command;
  108.             }
  109.             if ( ( $realType == "blendShapePanel")
  110.                     && (!`licenseCheck -m "edit" -typ "complete"`)) {
  111.                 //
  112.                 // The user needs a Maya Complete license to use
  113.                 // the BlendShape panel, so don't
  114.                 // bother offerring it as a choice (would just
  115.                 // bring up a useless blank panel anyway)
  116.                 continue;
  117.             }
  118.             $item = `menuItem -l $label -ecr false
  119.                 -c ($command+" -e -rp "+$panelName+" "+$i)`;
  120.  
  121.             if (`panel -q -to $i`) {
  122.                 menuItem -e -enable false $item;
  123.             }
  124.             $count++;
  125.         }
  126.     }
  127. }
  128.  
  129. global proc buildNamedArrangementsNow( string $menuName ) 
  130. {
  131.     string $configLabel;
  132.     string $arrs[];
  133.     int $i;
  134.     int $nArr = 0;
  135.  
  136.     menu -e -deleteAllItems $menuName;
  137.     setParent -m $menuName;
  138.  
  139.     $arrs = `getPanel -allConfigs`;
  140.     $nArr = size($arrs);
  141.  
  142.     for ($i = 0; $i < $nArr; $i++) {
  143.         $configLabel = `panelConfiguration -q -l $arrs[$i]`;
  144.         if ("Current Layout" != $configLabel) {
  145.             menuItem -l $configLabel 
  146.                 -annotation "Change layout of panels"
  147.                 -c ("setNamedPanelLayout \"" + $configLabel + "\"");
  148.         }
  149.     }
  150.  
  151.     menuItem -divider true;
  152.     menuItem -l "Edit Layouts..." 
  153.         -annotation "Edit Layouts: Edit the panel layouts"
  154.         -c "panelEditor \"Layouts\"";
  155. }
  156.     
  157. global proc tearOffCopyItemCmd(string $panelType, string $srcPanel) {
  158.  
  159.     string $cmd;
  160.     string $type;
  161.  
  162.     if ("scriptedPanel" == $panelType) {
  163.         $type = `scriptedPanel -q -type $srcPanel`;
  164.         $cmd = ("scriptedPanel -toc "+ $srcPanel +" -type "+ $type);
  165.         
  166.     } else {
  167.         $cmd = ($panelType + " -toc " + $srcPanel);
  168.     }
  169.     $newName = `eval $cmd`;
  170.     panel -e -label `interToUI $newName` $newName;
  171. }
  172.  
  173. global proc buildPanelItemsNow ( string $panelName, string $menuName )
  174. {
  175.     string $panelControl = `panel -q -control $panelName`;
  176.  
  177.     // if the menu name is specified, use it.  Otherwise, assume
  178.     // it is the pop-up menu and build the name appropriately.
  179.     //
  180.     string $popMenuName;
  181.     if ( $menuName == "" ){
  182.         $popMenuName = ($panelControl + "|" + $panelName + "Pop1");
  183.     } else {
  184.         $popMenuName = $menuName;
  185.     }
  186.     string $panelType = `getPanel -typeOf $panelName`;
  187.     string $itemName;
  188.  
  189.     setParent -m $popMenuName;    
  190.  
  191.     // The camera commands depend on the panel having focus for
  192.     // getting the camera in the view.
  193.     setFocus $panelName;
  194.  
  195.     if (0 != `menu -q -numberOfItems $popMenuName`) {
  196.         if ($panelType == "modelPanel" && $menuName == "")
  197.             menuItem -e -l `modelPanel -q -camera $panelName` menuTitle;
  198.  
  199.         return;
  200.     }
  201.  
  202.     // Titles are only needed for pop-up menu
  203.     //
  204.     if ( $menuName == "" ){
  205.         if ($panelType == "modelPanel"){
  206.             menuItem -l `modelPanel -q -camera $panelName` menuTitle;
  207.         }
  208.         else {
  209.             menuItem -l `panel -q -label $panelName` menuTitle;
  210.         }
  211.         menuItem -divider true;
  212.         menuItem -divider true;
  213.     }
  214.  
  215.     string $menu = `menuItem -l "Perspective" -subMenu true`;
  216.     menuItem -e -postMenuCommand
  217.            ("buildPerspLookthruMenu "+$menu+" "+$panelName) $menu;
  218.     setParent -m ..;
  219.  
  220.     $menu = `menuItem -l "Orthographic" -subMenu true`;
  221.        menuItem -e -postMenuCommand
  222.            ("buildOrthoLookthruMenu "+$menu+" "+$panelName) $menu;
  223.     setParent -m ..;
  224.     menuItem -l "Look Through Selected"
  225.         -command ("lookThroughSelected "+$panelName);
  226.     menuItem -divider true;
  227.  
  228.     $menu = `menuItem -l "Panel" -subMenu true`;
  229.     menuItem -e -postMenuCommand
  230.         ("buildOtherPanelSubItemsNow "+$menu+" "+$panelName) $menu;
  231.     setParent -m ..;
  232.  
  233.  
  234.     menuItem -l "Layouts" -subMenu true -tearOff true;
  235.         menuItem -label "Single Pane" -command "SingleViewArrangement"
  236.             -annotation (getRunTimeCommandAnnotation("SingleViewArrangement"));
  237.  
  238.         menuItem -label "Two Panes Side by Side" -command "TwoSideBySideViewArrangement"
  239.             -annotation (getRunTimeCommandAnnotation("TwoSideBySideViewArrangement"));
  240.         menuItem -label "Two Panes Stacked" -command "TwoStackedViewArrangement"
  241.             -annotation (getRunTimeCommandAnnotation("TwoStackedViewArrangement"));
  242.  
  243.         menuItem -label "Three Panes Split Top" -command "ThreeTopSplitViewArrangement"
  244.             -annotation (getRunTimeCommandAnnotation("ThreeTopSplitViewArrangement"));
  245.         menuItem -label "Three Panes Split Left" -command "ThreeLeftSplitViewArrangement"
  246.             -annotation (getRunTimeCommandAnnotation("ThreeLeftSplitViewArrangement"));
  247.         menuItem -label "Three Panes Split Bottom" -command "ThreeBottomSplitViewArrangement"
  248.             -annotation (getRunTimeCommandAnnotation("ThreeBottomSplitViewArrangement"));
  249.         menuItem -label "Three Panes Split Right" -command "ThreeRightSplitViewArrangement"
  250.             -annotation (getRunTimeCommandAnnotation("ThreeRightSplitViewArrangement"));
  251.  
  252.         menuItem -label "Four Panes" -command "FourViewArrangement"
  253.             -annotation (getRunTimeCommandAnnotation("FourViewArrangement"));
  254.  
  255.         menuItem -divider true;
  256.  
  257.         menuItem -label "Previous Arrangement" -command "PreviousViewArrangement"
  258.             -annotation (getRunTimeCommandAnnotation("PreviousViewArrangement"));
  259.         menuItem -label "Next Arrangement" -command "NextViewArrangement"
  260.             -annotation (getRunTimeCommandAnnotation("NextViewArrangement"));
  261.  
  262.     setParent -menu ..;
  263.  
  264.     $menu = `menuItem -l "Saved Layouts" -subMenu true`;
  265.     menuItem -e -pmc ("buildNamedArrangementsNow " + $menu) $menu;
  266.     setParent -m ..;
  267.  
  268.  
  269.     menuItem -divider true;
  270.  
  271.     menuItem -l "Tear Off..." -ecr false 
  272.         -c ($panelType + " -e -to " + $panelName + ";fillEmptyPanes;");
  273.     $itemName = `menuItem -l "Tear Off Copy..." -ecr false 
  274.                         -c ("tearOffCopyItemCmd " +$panelType + " " + $panelName)`;
  275.     if (`panel -q -iu $panelName`) {
  276.         menuItem -e -enable false $itemName;
  277.     }
  278.  
  279.     menuItem -divider true;
  280.  
  281.     menuItem -l "Panel Editor..." -c "panelEditor \"Panels\"";
  282.     
  283.     //    Create Context Sensitive Help Menu.
  284.     //
  285.     if (hasContextHelpProc($panelName))
  286.     {
  287.         doHelpSubMenu $panelName $menuName;
  288.     }//if
  289. }
  290.  
  291. global proc buildPanelPopupMenu (string $panelName) {
  292.  
  293.     // Build the common menu if it has not already been
  294.     // built. (and this is not a torn-off panel)
  295.     //
  296.     if ( !`panel -q -tearOff $panelName` ) {
  297.         string $panelControl = `panel -q -control $panelName`;
  298.         if ( `menuBarLayout -exists $panelControl` ){
  299.             setParent $panelControl;
  300.             string $ma[] = `menuBarLayout -q -menuArray $panelControl`;
  301.             int $found = 0;
  302.             int $i;
  303.             for ( $i=0; $i<size($ma) && $found == 0; $i++ ){
  304.                 if ( $ma[$i] == "Panels" ){
  305.                     $found = 1;
  306.                 }
  307.             }
  308.             if ( $found == 0 ){
  309.                 setParent $panelControl;
  310.                 string $menuName = `menu -helpMenu true 
  311.                             -l "Panels" 
  312.                             -familyImage "menuIconPanels.xpm"
  313.                             Panels`;
  314.                 menu -e -pmc ("buildPanelItemsNow "+$panelName+" "+$menuName) $menuName;
  315.             }
  316.         }
  317.     } else {
  318.         string $panelControl = `panel -q -control $panelName`;
  319.         if ( `menuBarLayout -exists $panelControl` ){
  320.             setParent $panelControl;
  321.             string $ma[] = `menuBarLayout -q -menuArray $panelControl`;
  322.             int $found = 0;
  323.             int $i;
  324.             //     Check for existing Help Menu.
  325.             //
  326.             for ( $i=0; $i<size($ma) && $found == 0; $i++ ){
  327.                 if ( $ma[$i] == "HelpMenu" ){
  328.                     $found = 1;
  329.                 }
  330.             }
  331.             if ( $found == 0 ){
  332.                 doHelpMenu($panelName,$panelControl);
  333.             }
  334.         }
  335.     }
  336. }
  337.  
  338.  
  339.  
  340.